<template>
	<view class="wrap">
		<view class="orderItem common">
			<view class="innerItem spaceBet">
				<view class="itemConImg">
					<image class="samePar" src="../../../static/images/groupService/ttIimg.png"></image>
				</view>
				<view class="itemConDet">
					<view class="itemTit multiEllip clamp2">{{orderDet.objName}}</view>
					<view class="midCon spaceBet">
						<view>服务项目{{orderDet.serviceNum}}项</view>
						<view class="itemStatus waitPay" v-if="orderDet.payStatus == 0 && orderDet.actMoney == 0">待付款(等待确认价格)</view>
						<!-- <view class="itemStatus waitPay">待付款(等待确认价格)</view> -->
						<view class="itemStatus waitPay" v-if="orderDet.payStatus == 0 && orderDet.actMoney > 0">待付款</view>
						<view class="itemStatus wait" v-if="orderDet.payStatus == 1 && orderDet.serviceStatus == 1">待服务</view>
						<view class="itemStatus wait" v-if="orderDet.payStatus == 1 && orderDet.serviceStatus == 2">服务中</view>
						<!-- <view class="itemStatus hasComp">已完成(待评价)</view> -->
						<view class="itemStatus hasComp" v-if="orderDet.payStatus == 6">已完成</view>
						<view class="itemStatus" v-if="orderDet.payStatus == 7">已取消</view>
					</view>
				</view>
			</view>
			<!-- 实付款 -->
			<view class="actPay spaceBet" v-if="orderDet.actMoney > 0">
				<block v-if="orderDet.payStatus >= 1">
					<view>实付款</view>
					<view class="actPayNum">
						<text class="currPrice"><text class="unit">¥</text>{{orderDet.actMoney}}</text>
					</view>
				</block>
				<block v-else>
					<block v-if="orderDet.actMoney > 0">
						<view>应付款</view>
						<view class="actPayNum">
							<text class="currPrice"><text class="unit">¥</text>{{orderDet.actMoney}}</text>
						</view>
					</block>
				</block>
			</view>
		</view>
		<view class="ogzItem">
			<view class="ogzName spaceBet">
				<text>{{orderDet.ogzName}}</text>
				<!-- <text class="iconfont icon-daohang" @tap="goCurrPos"></text> -->
			</view>
			<view class="ogzAdd"><text class="iconfont icon-weizhi"></text><text>{{orderDet.ogzAddress}}</text></view>
		</view>
		
		<!-- 联系客户 -->
		<view class="contract common spaceBet" @tap="makePhoneCall">
			<view class="infoTit">联系机构</view>
			<view class="iconfont icon-dianhua"></view>
		</view>
		<view class="basicInfo common">
			<view class="infoTit">套餐内容({{orderDet.serviceNum}}项)</view>
			<view class="infoCon">
				<block v-if="orderDet.payStatus == 0 || orderDet.payStatus == 7">
					<view class="infoItem"
						v-for="(item,index) in tcList"
						:key="index"
					>{{(index+1)}}.{{item.serviceName}}</view>
				</block>
				<block v-else-if="orderDet.payStatus == 1 || orderDet.payStatus == 6">
					<view class="infoItem"
						v-for="(item,index) in tcList"
						:key="index"
					>
						<view class="topInfoItem multiEllip clamp2">{{(index+1)}}.{{item.serviceName}}</view>
						<view class="botInfoItem spaceBet">
							<view>完成日期:{{item.signTime == '' ? '等待机构完成' : item.signTime}}</view>
							<view class="infoBtn" v-if="item.pjScore > 0" @tap="viewPj(index)">查看评价</view>
							<view class="infoBtn goPj" v-if="item.signTime != '' && item.pjScore == 0" @tap="goPj(index)">去评价</view>
						</view>
					</view>
				</block>
			</view>
		</view>
		<!-- 团队信息 -->
		<view class="basicInfo common">
			<view class="infoTit">团队信息</view>
			<view class="infoCon">
				<view class="infoItem spaceBet">
					<view class="itemTxt">团体名称</view>
					<view>{{orderDet.orderOgzName}}</view>
				</view>
				<view class="infoItem spaceBet">
					<view class="itemTxt">团体人数</view>
					<view>{{orderDet.groupAllNum}}人</view>
				</view>
				<view class="infoItem spaceBet">
					<view class="itemTxt">负责人信息</view>
					<view>{{orderDet.orderLxr}} {{orderDet.orderLxrMobile}}</view>
				</view>
			</view>
		</view>
		<!-- 订单信息 -->
		<view class="basicInfo common">
			<view class="infoTit">订单信息</view>
			<view class="infoCon">
				<view class="infoItem spaceBet">
					<view class="itemTxt">下单时间</view>
					<view>{{orderDet.addTime}}</view>
				</view>
				<view class="infoItem spaceBet">
					<view class="itemTxt">订单编号</view>
					<view>{{orderDet.orderNoLocal}}</view>
				</view>
				<view class="infoItem spaceBet" v-if="orderDet.payStatus == 0 && orderDet.actMoney == 0">
					<view class="itemTxt">订单状态</view>
					<view>等待和机构确认价格中...</view>
				</view>
				<view class="infoItem spaceBet" v-if="orderDet.payStatus == 0 && orderDet.actMoney > 0">
					<view class="itemTxt">订单状态</view>
					<view>待支付</view>
				</view>
				<view class="infoItem spaceBet" v-if="orderDet.payStatus == 1 && orderDet.serviceStatus == 1">
					<view class="itemTxt">订单状态</view>
					<view>待服务</view>
				</view>
				<view class="infoItem spaceBet" v-if="orderDet.payStatus == 1 && orderDet.serviceStatus == 2">
					<view class="itemTxt">订单状态</view>
					<view>服务中</view>
				</view>
				<view class="infoItem spaceBet" v-if="orderDet.payStatus == 6">
					<view class="itemTxt">订单状态</view>
					<view>已完成</view>
				</view>
				<view class="infoItem spaceBet" v-if="orderDet.payStatus == 7">
					<view class="itemTxt">订单状态</view>
					<view>已取消</view>
				</view>
				<view class="infoItem spaceBet"  v-if="orderDet.payAccount != ''">
					<view class="itemTxt">支付方式</view>
					<view>{{orderDet.payAccount == 'wx' ? '微信' : '支付宝'}}</view>
				</view>
			</view>
		</view>
		<button class="comBtn" v-if="orderDet.payStatus == 0 && orderDet.actMoney > 0" @tap="goPay">去支付</button>
		<!-- <button class="comBtn spec">去评价</button> -->
		<!-- <button class="comBtn spec">查看评价</button> -->
		<!-- 团体订单评价因需要在每个子项目中包括签到 以及对每个子项目的评价，暂时未做 -->
	</view>
</template>

<script>
	import { getZxOrderInfo } from '@/api/xlzx/index'
	export default {
		data(){
			return{
				orderId:'',
				orderDet:[],
				tcList:[],
				isRefreshFlag:false
			}
		},
		onLoad(options){
			this.orderId = options.orderId;
			this.loadOrderInfo();
		},
		onShow(){
			if(this.isRefreshFlag){
				this.loadOrderInfo();
			}
		},
		onHide(){
			this.isRefreshFlag = false;
		},
		onUnload(){
			uni.removeStorageSync('groupField');
			if(this.isRefreshFlag){
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2];
				prevPage.$vm.isRefreshFlag = true;
			}
		},
		methods:{
			viewPj(){
				uni.navigateTo({
					url:'../groupOrderPj/groupOrderPj?orderId=' + this.orderId
				})
			},
			goPj(index){
				var serviceName = this.tcList[index].serviceName,
					serviceId = this.tcList[index].serviceId;
				var groupField = { objName:this.orderDet.objName,serviceName:serviceName,serviceId:serviceId };
				uni.setStorageSync('groupField',groupField);
				uni.navigateTo({
					url:'../addGroupOrderPj/addGroupOrderPj?serviceId=' + serviceId + '&fromPage=groupOrder'
				})
			},
			goPay(){
				uni.navigateTo({
					url:'../../subIndex/orderPay/orderPay?orderId=' + this.orderId + '&fromPage=gsOrderDet'
				})
			},
			goCurrPos(){
				// var lon = this.orderDet.ogzLon,
				// 	lat = this.orderDet.ogzLat,
				// 	ogzName = this.orderDet.ogzName;
				// this.util.openMapNaviagtion(lon,lat,ogzName);
			},
			makePhoneCall(){
				uni.makePhoneCall({
					phoneNumber:this.orderDet.ogzMobile
				})
			},
			loadOrderInfo(){
				var field = {id:this.orderId}
				uni.showLoading({title:'加载中...', mask: true });
				getZxOrderInfo(field).then(res=>{
					//console.log(res)
					this.orderId = res.data.datas.id;
					this.orderDet = res.data.datas;
					this.tcList = res.data.datas.tcList;
				}).catch(err=>{
					console.log(err)
				});
			}
		}
	}
</script>

<style lang='scss'>
	@import '@/static/scss/orderDet.scss';
	page{
		background: $pss-bg-primary;
	}
</style>